--
-- Author: mm
-- Date: 2018-04-09 14:42:17
--
-- NewActivityDungeonsFailView
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.ActivityFailScene

function ClassRef:init()
	self._ui.Button_close:addClickEventListener(function()
			executeFunc(self._onOperate,"close_NewActivityDungeonsResultView", self._data)
			self:closeView()
		end)
end

-- enum GRADE {
-- 	NONE = 0; // 无效评级
-- 	COPPER  = 1; // 铜杯
-- 	SILVER  = 2; // 银杯
-- 	GOLD    = 3; // 金杯
-- }
-- message S2C_WorldEventResultNotify {
-- 	int32 id = 1; // 玩法id
-- 	int32 residualRewardTimes = 2; // 剩余奖励次数
-- 	GRADE grade = 3; // 最终评级
-- 	int32 score = 4; // 最终得分
-- 	int32 eventPoint = 5; // 获得活动点数
-- }

local string_format = string.format

function ClassRef:refreshContent( dataTemp )
	self._data = dataTemp

	local eventModeConf = GD:queryEventModeById( dataTemp.id )
	local evaluateType = tonumber( eventModeConf.evaluateType )
	local condition = string.split( eventModeConf.condition, ";" )[1]

	-- 1=高于限定回合
	-- 2=小于限定时间
	-- 3=高于限定血量
	-- 4=灰烬碎片数量
	-- 5=失败方格子数
	local minimumReq = ""
	local realGrade = ""
	if 1 == evaluateType then -- 狮心号角：回合数
		minimumReq = string_format(L("%s (%s)"), string_format(L("LionNotice"), condition), L("copper_cup"))
		realGrade = string_format(L("LionNotice"), dataTemp.score or 0)
	elseif 2 == evaluateType then
		minimumReq = string_format(L("%s (%s)"), string_format( L("ZombieNotice"),condition), L("copper_cup"))
		realGrade = string_format(L("ZombieNotice"), dataTemp.score or 0)
	elseif 3 == evaluateType then
		minimumReq = string_format(L("%s (%s)"), string_format(L("KingofFightersNotice"), condition ), L("copper_cup"))
		realGrade = string_format(L("KingofFightersNotice"), dataTemp.score or 0)
	elseif 4 == evaluateType then
		minimumReq = string_format(L("%s (%s)"), string_format(L("lua_code_text_407"), condition ), L("copper_cup"))
		realGrade = string_format(L("lua_code_text_407"), dataTemp.score or 0)
	elseif 5 == evaluateType then
		minimumReq = string_format(L("%s (%s)"), string_format(L("ChessWinNotice"), condition), L("copper_cup"))
		realGrade = dataTemp.reason
	else
		print( " ----------------->>>> 未知活动副本类型 " )
	end
	self._ui.Panel:getChildByName( "text" ):setString( minimumReq )
	self._ui.Panel:getChildByName( "tips_1" ):setString( realGrade )
end

function ClassRef:refreshSecretContent( dataTemp )
	if dataTemp.title2 then
		self._ui.Panel:getChildByName( "tips_2" ):setString(dataTemp.title2)
	end	

	self._ui.Panel:getChildByName( "text" ):setString(string_format(L("lua_code_text_348"), tostring(dataTemp.need)))
	self._ui.Panel:getChildByName( "tips_1" ):setString(string_format(L("lua_code_text_348"), tostring(dataTemp.score)))
end

return ClassRef
